package cn.xuchunh.campusbbs.ui.activities;

import android.content.Context;
import android.content.Intent;

import cn.xuchunh.campusbbs.R;
import cn.xuchunh.campusbbs.bean.Album;
import cn.xuchunh.campusbbs.ui.fragments.PhotoListFragment;
import cn.xuchunh.campusbbs.utils.IntentParamsKey;

/**
 * Created by XuChunH on 2015/10/23.
 */
public class PhotoListActivity extends FragmentContainerActivity<PhotoListFragment> {

    private int userId;
    private Album album;

    public static void launch(Context context, int userId, Album album) {
        Intent intent = new Intent(context, PhotoListActivity.class);
        intent.putExtra(IntentParamsKey.USER_ID, userId);
        intent.putExtra(IntentParamsKey.ALBUM, album);
        context.startActivity(intent);
    }

    @Override
    protected PhotoListFragment getFrament() {
        return PhotoListFragment.newInstance(album.getId(), userId);
    }

    @Override
    protected int containerId() {
        return R.id.container;
    }

    @Override
    protected int createContentRes() {
        return R.layout.layout_simple_container;
    }

    @Override
    protected void beforeInitView() {
        Intent intent = getIntent();
        if (intent != null) {
            album = intent.getParcelableExtra(IntentParamsKey.ALBUM);
            userId = intent.getIntExtra(IntentParamsKey.USER_ID, 1);
        }
        setShowHomeUp(true);
        setTitle(album.getTitle());
    }
}
